#include "../MonitorUI/GLImage.hpp"
#include <gtkmm/window.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#include <thread>

using namespace std::chrono_literals;

class testWindow:public Gtk::Window
{
    Gtk::Box vbox;
  public:
    testWindow(Gtk::Widget* widget)
      : vbox(Gtk::Orientation::VERTICAL)
    {
      set_default_size(500,500);
      vbox.append(*widget);
      set_child(vbox);
    }
};

int main()
{
  gst_init(nullptr,nullptr);
  auto app=Gtk::Application::create("org.GLImage.test");
  GLImage img;
  testWindow window(img.GetGtkObject());
  app->signal_activate().connect([&](){
    app->add_window(window);
    window.set_visible(true);
  });
  std::thread workThread([&](){
    std::this_thread::sleep_for(5s);
    int width,height,comp;
    unsigned char* data=stbi_load("/home/shenzhe/Pictures/test1080p.png",&width,&height,&comp,3);
    img.ShowImage({
      .data=data,
      .data_size=1920*1080*3
    });
    stbi_image_free(data);
  });
  app->run();
  workThread.join();
}
